import router from '@system.router';
import prompt from '@system.prompt';

export default {
    data: {
        heads: [],
        components: [],
        details: [],
        price: 61.6,
        isBuyNow: false,
        classes: [
            { name: "芭比粉(0.7mm)", price: 61.6 },
            { name: "金属银(0.7mm)", price: 61.6 },
            { name: "拉丝黑(0.7mm)", price: 61.6 }
        ],
        amount: 1
    },
    onInit() {
        for (let i = 1; i <= 5; i++)
             this.heads.push("/common/images/detail/pen" + i + ".png");
        for (let i = 1; i <= 4; i++)
            this.components.push("/common/images/detail/layout" + i + ".jpg");
        for (let i = 1; i <= 5; i++)
            this.details.push("/common/images/detail/detail" + i + ".jpg");
    },
    goBack() {
        router.back();
    },
    addCart() {
        this.isBuyNow = false;
        this.$element("pop_up").show();
    },
    buyNow() {
        this.isBuyNow = true;
        this.$element("pop_up").show();
    },
    closePopUp() {
        this.$element("pop_up").close();
    },
    goPurchase() {
        router.push({ uri: "pages/purchase/purchase" });
    },
    putCart() {
        prompt.showToast({
            message: "添加成功，宝贝在购物车等你~",
            duration: 1500
        });
        this.$element("pop_up").close();
    },
    amountInc() {
        ++this.amount;
    },
    amountDec() {
        if (this.amount > 1)
            --this.amount;
    }
}
